<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品规格管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- <h1>菜单管理</h1> -->
    <el-button type="primary" size="small" @click="change">添加</el-button>
    <v-list @edit="edit" ref="listed" @rolad="rolad"></v-list>
    <!-- 分页器 -->
    <v-pagtion :totals="totalnum" @search="search"></v-pagtion>
    <v-dialog
      :dialist="dialog"
      @cancle="cancle"
      ref="dialogs"
      @rolad="rolad"
    ></v-dialog>
  </div>
</template>

<script>
import vList from "./list";
import vDialog from "./dialog";
import vBread from "../../common/elBread";
import vPagtion from "../../common/elPag";
import {countSpecs} from "../../util/axios"
// import {mapActions,mapGetters} from "vuex"
export default {
  components: {
    vList,
    vDialog,
    vBread,
    vPagtion,
  },
  data() {
    return {
      dialog: {
        isShow: false,
        isAdd: true,
      },
      totalnum:0
    };
  },
  methods: {
    //添加功能
    change() {
      this.dialog.isShow = true;
      this.dialog.isAdd = true;
    },
    cancle(e) {
      this.dialog.isShow = e;
    },
    //子组件的编辑功能，由父组件dialog
    edit(e) {
      this.$refs.dialogs.lookup(e);
      this.dialog.isAdd = false;
      this.dialog.isShow = true;
    },
    //分页器上定义的搜索功能
    search(e) {
       this.$refs.listed.search(e);
    },
    rolad(){
      //重新调取数据
      this.$refs.listed.getSpecsList();
      this.getcount()
    },
    getcount(){
        countSpecs().then(res=>{
          if(res.code ==200){
            this.totalnum = res.list[0].total;
          }
      })
    }
  },

  mounted() {
     this.getcount()
  },
};
</script>

<style scoped>
.el-button {
  margin-top: 15px;
}
</style>